import { useIntl } from '@umijs/max';
import React from 'react';
import Styles from './StationIncome.less';

// 定义组件数据类型
export interface StationTotalIncomeData {
  CumulativeIncome?: number;
  TodayIncome?: number;
}

// 定义组件属性类型
interface StationIncomeProps {
  data: StationTotalIncomeData;
}

// 创建组件
const StationIncome: React.FC<StationIncomeProps> = ({ data }) => {
  // 格式化数据，确保精确到小数点后两位
  const formattedCumulativeIncome = data.CumulativeIncome?.toFixed(2) || '0.00';
  const formattedTodayIncome = data.TodayIncome?.toFixed(2) || '0.00';
  const intl = useIntl();
  return (
    <div className={Styles.stationIncome}>
      <div className={Styles.incomeItemBg}></div>
      <div className={Styles.incomeItemInner}>
        <p className={Styles.incomeItem}>
          <strong className={Styles.incomeLabel}>
            {intl.formatMessage({ id: 'bigdata.TotalS' })}:
          </strong>
          <span className={Styles.incomeValue}>{formattedCumulativeIncome}</span>
        </p>
        <p className={Styles.incomeItem}>
          <strong className={Styles.incomeLabel}>
            {intl.formatMessage({ id: 'bigdata.dayRevenu' })}:
          </strong>
          <span className={Styles.incomeValue}>{formattedTodayIncome}</span>
        </p>
      </div>
    </div>
  );
};

export default StationIncome;
